package com.jincp.common.dialog;


import com.jincp.common.R;

import static android.view.Gravity.CENTER;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

/**
 * Created by jinchunping on 2018/10/30.
 */

public abstract class BaseDialogBuilder<T extends BaseDialogBuilder, D extends BaseDialogFragment> {
    public int mWidth = WRAP_CONTENT;
    public int mHeight = WRAP_CONTENT;
    public int mGravity = CENTER;
    public int mOffsetX = 0;
    public int mOffsetY = 0;
    public float mBackGroundLevel = 0.5f;
    public int mAnimation = R.style.SlideBottomAnimation;
    public boolean mOutCancel = true;

    public T setSize(int mWidth, int mHeight) {
        this.mWidth = mWidth;
        this.mHeight = mHeight;
        return (T) this;
    }

    public T setGravity(int mGravity) {
        this.mGravity = mGravity;
        return (T) this;
    }

    public T setOffsetX(int mOffsetX) {
        this.mOffsetX = mOffsetX;
        return (T) this;
    }

    public T setOffsetY(int mOffsetY) {
        this.mOffsetY = mOffsetY;
        return (T) this;
    }

    public T setBackgroundLevel(float mBackGroundLevel) {
        this.mBackGroundLevel = mBackGroundLevel;
        return (T) this;
    }


    public T setAnimation(int mAnimation) {
        this.mAnimation = mAnimation;
        return (T) this;
    }

    public T setOutCancel(boolean mOutCancel) {
        this.mOutCancel = mOutCancel;
        return (T) this;
    }

    protected abstract D build();

    protected void clear() {
        this.mWidth = WRAP_CONTENT;
        this.mHeight = WRAP_CONTENT;
        this.mGravity = CENTER;
        this.mOffsetX = 0;
        this.mOffsetY = 0;
        this.mOutCancel = true;
    }
}
